package com.sina.finance.api.framework.utils;

import java.util.HashSet;
import java.util.Set;

/**
 * @File name : CollectionUtils
 * @Description :
 * @Creator : cuiyong
 * @CreateTime : 15/11/11 18:11
 * @Version : 1.0
 * @Update records:
 * 1.0 15/11/11 by cuiyong: Created
 * All rights served : SINA Corporation
 */
public class CollectionUtils {
    public static <T> Set<T> intersection(Set<T> collectionA, Set<T> collectionB) {
        Set<T> result = new HashSet<T>();
        result.addAll(collectionA);
        result.retainAll(collectionB);
        return result;
    }

    public static <T> Set<T> union(Set<T> collectionA, Set<T> collectionB) {
        Set<T> result = new HashSet<T>();
        result.addAll(collectionA);
        result.addAll(collectionB);
        return result;
    }

    public static <T> Set<T> complement(Set<T> collectionA, Set<T> collectionB) {
        Set<T> result = new HashSet<T>();
        result.addAll(collectionA);
        result.removeAll(collectionB);
        return result;
    }
}
